import request from '@/router/axios';

/**
 * @param current 当前页
 * @param size 每页数据量
 * @returns {AxiosPromise}
 */
export const getParentList = (current, size,params) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/product/list',
    method: 'get',
    params: {
      'areaTypeEnum':'lineSide',
      ...params,
      current,
      size,
    }
  })
}


export const getChildList = (current, size, transferId) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/item/product/list',
    method: 'get',
    params: {
      transferId,
      current,
      size,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/product/save',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/update',
    method: 'post',
    data: row
  })
}

export const remove = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/delete',
    method: 'post',
    params: {
      id,
    }
  })
}


export const commit = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/product/commit',
    method: 'post',
    params: {
      id,
    }
  })
}


export const back = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/cancel',
    method: 'post',
    params: {
      id,
    }
  })
}


export const getBusinessList = (current,size,params) => {
  return request({
    url: '/api/hg-logistics/business/type/batchList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      inOutTypeEnumList:'in_product_allot,out_product_allot'
    }
  })
}


export const choose = (form) => {
  return request({
    url: '/api/hg-logistics/inventory/manage/choose',
    method: 'post',
    data: form
  })
}


export const addDetail = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/item/save',
    method: 'post',
    data: row
  })
}


export const getManageList = (current,size,id) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/item/update',
    method: 'get',
    params: {
      id,
      current,
      size,
    }
  })
}


export const removeDetailList = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/item/delete',
    method: 'post',
    params: {
      id,
    }
  })
}

export const removeDetail = (id,itemId) => {
  return request({
    url: '/api/hg-logistics/inventory/transfer/item/deleteItem',
    method: 'post',
    params: {
      id,
      itemId,
    }
  })
}

export const getAreaList = (current, size,params) => {
  return request({
    url: '/api/hg-logistics/inventory/area/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      "areaType":"lineSide"
    }
  })
}

export const getById = (id) => {
  return request({
    url: '/api/hg-public/material/info/info2',
    method: 'get',
    params: {
      id,
    }
  })
}

export const getMaterialList = (current,size,data) => {
  return request({
    url: '/api/hg-public/material/info/page',
    method: 'get',
    params: {
      ...data,
      current,
      size,
    }
  })
}

export const getStorageAreaList = (current,size,data) => {
  return request({
    url: '/api/hg-logistics/inventory/area/list',
    method: 'get',
    params: {
      ...data,
      current,
      size,
    }
  })
}
